/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function loadState(){
    var country = document.getElementById('country').value;
 
 //  alert(country);
    if(country == 0){
         //alert("2");
        document.getElementById('stateDiv').innerHTML = "<select name='state' id='state'></select> ";
        document.getElementById('cityDiv').innerHTML = " <select name='city' id='city'><option value = -1>-- Select --</option></select>";

        $.ajax({
            type: "POST",
            url: "controller/controller.php?action=getState&id="+Math.random(),
            data: "country="+country,
            cache: false,
            success: function(html){
        //        alert(html);
                document.getElementById('stateDiv').innerHTML = html;
        //   $("#stateDiv").add(html);
            }
        });
    }
    if(country == 1){

        document.getElementById('stateDiv').innerHTML = "<input type='text' name = 'state' id = 'state'/> ";
        document.getElementById('cityDiv').innerHTML = "<input type='text' name = 'city' id = 'city'/> ";
    }
}

function loadCity(){
  var state =  document.getElementById('state').value;
   //alert(document.getElementById('state').value);

      $.ajax({
            type: "POST",
            url: "controller/controller.php?action=getCity&id="+Math.random(),
            data: "state="+state,
            cache: false,
            success: function(html){
     //           alert(html);
                document.getElementById('cityDiv').innerHTML = html;
        //   $("#stateDiv").add(html);
            }
        });

    
}
